// Copyright (c) 2009 Luca Marrocco.
// Modified or written by Luca Marrocco for inclusion with codej.
// Licensed under the Apache License, Version 2.0 (the "License")
package codej.ast;

import codej.ast.*;

public class OperationExpression extends Expression {

	private Expression expression1;
	private ExpressionOperator operator;
	private Expression expression2;

	public OperationExpression(Expression expression1, ExpressionOperator operator, Expression expression2) {
		this.expression1 = expression1;
		this.operator = operator;
		this.expression2 = expression2;
		addChild(expression1);
		addChild(expression2);
	}

	@Override
	public void accept(Visitor visitor) {
		visitor.visit(this);
	}

	@Override
	public boolean equals(Object obj) {
		if (!obj.getClass().isAssignableFrom(OperationExpression.class))
			return false;
		OperationExpression anotherOperationExpression = (OperationExpression) obj;
		if (!expression1.equals(anotherOperationExpression.expression1))
			return false;
		if (!operator.equals(anotherOperationExpression.operator))
			return false;
		if (!expression2.equals(anotherOperationExpression.expression2))
			return false;
		return true;
	}

	public Expression getExpression1() {
		return expression1;
	}

	public Expression getExpression2() {
		return expression2;
	}

	public ExpressionOperator getOperator() {
		return operator;
	}

}
